package com.ma.po;

import com.mysql.cj.x.protobuf.MysqlxDatatypes;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

//@Component
//@ConfigurationProperties(prefix = "comment")
@Entity
@Table(name="t_comment")
//表明创建表时候的表名
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Comment {
    //昵称,邮箱,头像,评论内容,创建时间
    @Id
    @GeneratedValue
    private Long id;
    private String nickname;
    private String email;
    //private String comment;
    private String content;
    private String avatar;
    @Temporal(TemporalType.TIMESTAMP)
    private Date createTime;

    @ManyToOne
    private Blog blog;

    //评论实体的内部关联
    //多个子评论对应一个父评论
    @OneToMany(mappedBy = "parentComment")
    private List<Comment> replyComments = new ArrayList<>();
    @ManyToOne
    private Comment parentComment;

    private boolean adminComment;


}
